package com.edu.study.base.StuAnswerResultErrorDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.StuAnswerResultErrorDetail.domain.StuAnswerResultErrorDetail;
import com.edu.study.base.StuAnswerResultErrorDetail.service.IStuAnswerResultErrorDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生答题结果错题明细Controller
 * 
 * @author ruoyi
 * @date 2021-06-20
 */
@RestController
@RequestMapping("/study/stuAnswerResultErrorDetail")
public class StuAnswerResultErrorDetailController extends BaseController
{
    @Autowired
    private IStuAnswerResultErrorDetailService stuAnswerResultErrorDetailService;

    /**
     * 查询学生答题结果错题明细列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuAnswerResultErrorDetail stuAnswerResultErrorDetail)
    {
        startPage();
        List<StuAnswerResultErrorDetail> list = stuAnswerResultErrorDetailService.selectStuAnswerResultErrorDetailList(stuAnswerResultErrorDetail);
        return getDataTable(list);
    }

    /**
     * 导出学生答题结果错题明细列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:export')")
    @Log(title = "学生答题结果错题明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuAnswerResultErrorDetail stuAnswerResultErrorDetail)
    {
        List<StuAnswerResultErrorDetail> list = stuAnswerResultErrorDetailService.selectStuAnswerResultErrorDetailList(stuAnswerResultErrorDetail);
        ExcelUtil<StuAnswerResultErrorDetail> util = new ExcelUtil<StuAnswerResultErrorDetail>(StuAnswerResultErrorDetail.class);
        return util.exportExcel(list, "stuAnswerResultErrorDetail");
    }

    /**
     * 获取学生答题结果错题明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuAnswerResultErrorDetailService.selectStuAnswerResultErrorDetailById(id));
    }

    /**
     * 新增学生答题结果错题明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:add')")
    @Log(title = "学生答题结果错题明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuAnswerResultErrorDetail stuAnswerResultErrorDetail)
    {
        return toAjax(stuAnswerResultErrorDetailService.insertStuAnswerResultErrorDetail(stuAnswerResultErrorDetail));
    }

    /**
     * 修改学生答题结果错题明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:edit')")
    @Log(title = "学生答题结果错题明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuAnswerResultErrorDetail stuAnswerResultErrorDetail)
    {
        return toAjax(stuAnswerResultErrorDetailService.updateStuAnswerResultErrorDetail(stuAnswerResultErrorDetail));
    }

    /**
     * 删除学生答题结果错题明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultErrorDetail:remove')")
    @Log(title = "学生答题结果错题明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuAnswerResultErrorDetailService.deleteStuAnswerResultErrorDetailByIds(ids));
    }
}
